package com.lry.basic.algorithm.bit;

public class TestBitMaps {
    public static void main(String[] args) {
        BitMaps bitMaps = new BitMaps();
        String key = "bit";
        bitMaps.setBit(key,10,"1");
        System.out.println(bitMaps.getBit(key, 10));
        System.out.println(bitMaps.getBit(key, 2));

        bitMaps.setBit(key,100000,"1");
        System.out.println(bitMaps.getBit(key, 100000));
        System.out.println(bitMaps.getBit(key, 2099999999));

        //按字节统计置1位数
        System.out.println(bitMaps.bitCount(key));
        System.out.println(bitMaps.bitCount(key,0,1));
        System.out.println(bitMaps.bitCount(key,0,100000));

        //按位统计置1位数
        System.out.println(bitMaps.bitCountByBit(key,0,1));
        System.out.println(bitMaps.bitCountByBit(key,0,7));
        System.out.println(bitMaps.bitCountByBit(key,1,20));
        System.out.println(bitMaps.bitCountByBit(key,2,23));
        System.out.println(bitMaps.bitCountByBit(key,0,100000));

        //返回置位1的最小下标
        bitMaps.setBit(key,9,"1");
        System.out.println(bitMaps.bitPos(key));

    }
}
